86 REM ************************************* 87 REM * * 88 REM * CREATED FOR * 89 REM * * 90 REM * THE COMMODORE EDUCATIONAL GROUP * 91 REM * * 92 REM * BY * 93 REM * * 94 REM * GARRY G. KIZIAK * 95 REM * * 96 REM * COPYRIGHT 1982 * 97 REM * * 98 REM ************************************* 99 : 100 PRINT"[147]"; 110 DEF FNX(X)=X-INT(X/24)*24 120 DEF FNY(X)=X-INT(X/21)*21 130 V$="" 140 DOT$="........................":BL$=" " 150 G=13*4096:CR$=CHR$(13):DE$=CHR$(20):C=1:B=6:E=14:SX=30:SY=150:X1=0:Y1=0 160 PA=200:SP=0:SC=1024+80+3:AD=32608 170 GOSUB 960 180 GOSUB 870 190 GOSUB 930 200 GOSUB 850 210 PX=0:PY=0 220 P=SC+PY*40+PX:Q=PEEK(P):R=Q 230 R=(NOTRAND128)OR(NOT128ANDR) 240 POKE P,R 250 FOR I=1 TO 30:GET A$:IF A$="" THEN NEXT:GOTO 230 260 POKE P,Q 270 IF A$="" THEN PX=FNX(PX+1):GOTO 220 280 IF A$="[157]" THEN PX=FNX(PX-1):GOTO 220 290 IF A$="" THEN PY=FNY(PY+1):GOTO 220 300 IF A$="[145]" THEN PY=FNY(PY-1):GOTO 220 310 IF A$=DE$ THEN POKE P,PEEK(P) AND 127:GOTO 680 320 IF A$=" " THEN GOSUB 660:PX=FNX(PX+1):GOTO 220 330 IF A$=CR$ THEN PX=0:PY=FNY(PY+1):GOTO 220 340 IF A$="." THEN 740 350 IF A$="[147]" THEN GOSUB 820:GOTO 210 360 IF A$="" THEN GOSUB 830:GOTO 210 370 IF A$="+" THEN 780 380 IF A$="-" THEN 800 390 IF A$="Q" THEN POKE G+21,0:PRINT "[147]";:END 400 IF A$=">" THEN C=(C+1)AND15:POKE G+39,C 410 IF A$="" THEN B=(B+1)AND15:POKE 53281,B 420 IF A$="" THEN E=(E+1)AND15:POKE 53280,E 430 IF A$="" THEN X1=1-X1:GOSUB 900:GOSUB 870:GOTO 220 440 IF A$="" THEN Y1=1-Y1:GOSUB 900:GOSUB 870:GOTO 220 450 IF A$="[133]" THEN 580 460 IF A$="[134]" THEN 600 470 IF A$="[135]" THEN 620 480 IF A$="[136]" THEN 640 490 IF A$="" THEN 1510 500 IF A$="S" THEN 1270 510 IF A$="" THEN 1030 520 IF A$="" THEN 1070 530 IF A$=" " THEN 1430 540 IF A$="" THEN 210 550 IF A$="" THEN GOSUB 1860:GOTO 170 555 IF A$="\" THEN 690 556 IF A$="M" THEN POKE G+28,1 557 IF A$="H" THEN POKE G+28,0 560 GOTO 220 570 POKE G+21,0:GOSUB 930:GOSUB 870:GOSUB 850:GOTO 210 574 REM **************************** 575 REM * * 576 REM * MOVE ENTIRE SPRITE UP, * 577 REM * DOWN, LEFT, OR RIGHT * 578 REM * * 579 REM **************************** 580 J=PA*64:POKE 253,J-256*INT(J/256):POKE 254,J/256 590 SYS AD:GOSUB 850:GOTO220 600 J=PA*64+59:POKE 253,J-256*INT(J/256):POKE 254,J/256 610 SYS AD+42:GOSUB 850:GOTO220 620 J=PA*64:POKE 253,J-256*INT(J/256):POKE 254,J/256 630 SYS AD+88:GOSUB 850:GOTO220 640 J=PA*64:POKE 253,J-256*INT(J/256):POKE 254,J/256 650 SYS AD+118:GOSUB 850:GOTO220 655 REM **************************** 656 REM * * 657 REM * ERASE OR DELETE A POINT * 658 REM * * 659 REM **************************** 660 POKE P,46:PP=PA*64+PY*3+INT(PX/8) 670 POKE PP,PEEK(PP) AND 255-2^(7-(PX-INT(PX/8)*8)):RETURN 680 PX=FNX(PX-1):P=SC+PY*40+PX:GOSUB 660:GOTO 220 685 REM **************************** 686 REM * * 687 REM * ROTATE SPRITE 90 DEGREES * 688 REM * * 689 REM **************************** 690 HI=INT(PA/4):LO=PA*64-256*HI:POKE 251,LO:POKE 252,HI:SYS 32422 700 SYS 32443:SYS 32526:POKE 251,LO:POKE 252,HI 710 GET A$:IF A$<>"\" AND A$<>CR$ THEN 710 720 IF A$="\" THEN 700 730 GOTO 220 735 REM **************************** 736 REM * * 737 REM * PLOT A POINT * 738 REM * * 739 REM **************************** 740 POKE P,81 750 PP=PA*64+PY*3+INT(PX/8) 760 POKE PP,PEEK(PP) OR 2^(7-(PX-INT(PX/8)*8)) 770 PX=FNX(PX+1):GOTO 220 775 REM **************************** 776 REM * * 777 REM * NEXT OR PREVIOUS SPRITE * 778 REM * * 779 REM **************************** 780 IF PA<15 OR (PA>31ANDPA<63) OR(PA>127ANDPA<255) THEN PA=PA+1:GOTO570 790 GOTO 220 800 IF(PA>13ANDPA<16) OR (PA>32ANDPA<64) OR(PA>128ANDPA<256) THEN PA=PA-1:GOTO570 810 GOTO 220 815 REM **************************** 816 REM * * 817 REM * CLEAR SPRITE * 818 REM * * 819 REM **************************** 820 FOR X=0 TO 63:POKE PA*64+X,0:NEXT:GOSUB 850:RETURN 825 REM **************************** 826 REM * * 827 REM * REVERSE SPRITE * 828 REM * * 829 REM **************************** 830 FOR X=0 TO 63:Y=PEEK(PA*64+X):Y=(NOTYAND255) OR (NOT255ANDY):POKE PA*64+X,Y 840 NEXT:GOSUB 850:RETURN 845 REM **************************** 846 REM * * 847 REM * DISPLAY SPRITE ON SCREEN * 848 REM * * 849 REM **************************** 850 POKE 251,PA*64-INT(PA/4)*256:POKE 252,PA/4 860 SYS 32526:PRINT"":RETURN 865 REM **************************** 866 REM * * 867 REM * INITIALIZE SPRITE DATA * 868 REM * * 869 REM **************************** 870 POKE G+21,0:POKE 2040+SP,PA:POKE G+39,C 880 POKE G+SP*2,SX:POKE G+SP*2+1,SY:POKE G+23,Y1:POKE G+29,X1 890 POKE G+16,2^SP:POKE G+21,2^SP:RETURN 895 REM **************************** 896 REM * * 897 REM * EXPAND/CONTRACT SPRITE * 898 REM * * 899 REM **************************** 900 SX=17:IF X1=0 THEN SX=30 910 SY=138:IF Y1=0 THEN SY=150 920 RETURN 925 REM **************************** 926 REM * * 927 REM * DISPLAY EDITING SCREEN * 928 REM * * 929 REM **************************** 930 PRINT ""TAB(29)"[180] [167]":PRINT TAB(29)"[180]PAGE [167]" 940 PRINT TAB(29)"[204][175][175][175][175][175][175][175][175][186]":PRINT "[145][145]"TAB(34)PA 950 RETURN 960 PRINT " [164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164] [175][175][175][175][175][175][175][175][175][175]" 970 PRINT "  123456789012345678901234 [146]  SPRITE [157][157][157][157][157][157][157][157][157][157] EDITOR " 980 FOR X=1 TO 21 990 PRINT " "RIGHT$(" "+STR$(X),2)"[146]"DOT$" [146]":NEXT 1000 PRINT "  [146]" 1010 RETURN 1015 REM **************************** 1016 REM * * 1017 REM * PROMPT FOR NEW PAGE * 1018 REM * * 1019 REM **************************** 1020 IF IN$="" THEN PA=AP:GOTO 180 1030 LI=18:COL=30:LE=3:MSG$="[146]PAGE[146]":GOSUB 1700:AP=PA:PA=VAL(IN$) 1040 PRINTLEFT$(V$,LI)TAB(COL-1)" " 1050 IF IN$="" OR PA<13 OR (PA>15ANDPA<32)OR (PA>63ANDPA<128) OR PA>255 THEN PA=AP 1060 GOTO 180 1065 REM **************************** 1066 REM * * 1067 REM * DISPLAY RANGE OF SPRITES * 1068 REM * * 1069 REM **************************** 1070 POKE G+21,0:POKE G+16,0:POKE G+23,0:POKE G+29,0:GOSUB 1250 1080 LI=8:COL=6:LE=3:MSG$="[146]FROM PAGE:[146]" 1090 GOSUB 1700:GP=PG:PG=VAL(IN$):IFIN$="" THEN PRINT "[147]":GOTO 170 1100 IF PG<0 OR PG>255 OR (PG=0 AND IN$<>"0") THEN 1080 1110 LI=8:COL=22:MSG$="[146]TO PAGE:[146]" 1120 GOSUB 1700:PH=VAL(IN$):IF PH255 THEN 1110 1130 SW=PG 1140 SUM=0:EN=SW+7:IF EN>PH THEN EN=PH:IF SW>PH THEN 170 1150 GOSUB 1250:FOR I=SW TO EN:K=I-SW:M=K:IF M>3 THEN M=M-4 1160 POKE 2040+K,I:SUM=SUM+2^K 1170 POKE G+K*2,M*48+104:L=98:L1=10:IF K>3 THEN L=155:L1=17 1180 POKE G+K*2+1,L:POKE G+39+K,1:POKE G+21,SUM 1190 PRINT LEFT$(V$,L1)TAB(M*6+9)I 1200 NEXT 1210 PRINTLEFT$(V$,20)TAB(7)" [164][164][164][164][164][164][164][164][164]" 1220 PRINTTAB(7)"PRESS SPACE BAR[146] TO CONTINUE" 1230 GET A$:IF A$<>" "THEN 1230 1240 POKE G+21,0:PRINT "[147]":SW=EN+1:GOTO 1140 1250 PRINT "[147] [164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]" 1260 PRINT "  DISPLAY SPRITES [146]":RETURN 1265 REM **************************** 1266 REM * * 1267 REM * SAVE SPRITES TO DISK * 1268 REM * * 1269 REM **************************** 1270 POKE G+21,0:PRINT "[147] [164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]" 1280 PRINT "  SAVE SPRITE DATA [146]" 1290 LI=8:COL=6:LE=3:MSG$="[146]FROM PAGE:[146]" 1300 GOSUB 1700:PG=VAL(IN$):IF IN$="" THEN PRINT "[147]":GOTO 170 1310 IF PG<13 OR (PG>15 AND PG<32) OR (PG>63 AND PG<128) OR PG>255 THEN 1290 1320 LI=8:COL=22:MSG$="[146]TO PAGE:[146]":GOSUB 1700:PH=VAL(IN$) 1330 IF PH15 AND PH<32) OR (PH>63 AND PH<128) OR PH>255 THEN 1320 1340 BEG=PG*64:EN=PH*64+64:HI=INT(BEG/256):LO=BEG-HI*256 1350 LI=10:COL=12:LE=16:MSG$="[146]FILENAME:[146]":GOSUB 1700:FL$="0:"+IN$+",PRG,WRITE" 1360 OPEN 1,8,15,"I0":GOSUB 1810 1370 OPEN 2,8,1,FL$:GOSUB 1810 1380 PRINT#2,CHR$(LO);CHR$(HI); 1390 Y=2:FOR I=BEG TO EN:X=PEEK(I):PRINT#2,CHR$(X);:GOSUB 1810 1400 PRINT LEFT$(V$,12)TAB(12)MID$(""+"WRITING"+"[146]: ",Y)IN$:Y=3-Y:NEXT 1410 CLOSE 2:CLOSE 1 1420 PRINT "[147]":GOTO 170 1425 REM **************************** 1426 REM * * 1427 REM * LOAD SPRITES FROM DISK * 1428 REM * * 1429 REM **************************** 1430 POKE G+21,0:PRINT "[147] [164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]" 1440 PRINT "  LOAD SPRITE DATA [146]" 1450 LI=10:COL=12:LE=16:MSG$="[146]FILENAME:[146]":GOSUB 1700:FL$="0:"+IN$ 1460 IF IN$="" THEN PRINT "[147]":GOTO 170 1470 OPEN1,8,15,"I0" 1480 OPEN2,8,0,FL$:GOSUB 1810:CLOSE 2:CLOSE 1 1490 LOAD FL$,8,1 1500 END 1504 REM **************************** 1505 REM * * 1506 REM * COPY SPRITES TO ANOTHER * 1507 REM * AREA IN MEMORY * 1508 REM * * 1509 REM **************************** 1510 POKE G+21,0:PRINT "[147] [164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]" 1520 PRINT "  COPY SPRITE DATA [146]" 1530 PRINT LEFT$(V$,4)" [164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]":PRINT " ** SOURCE PAGES **" 1540 LI=7:COL=4:LE=3:MSG$="[146]FROM PAGE:[146]" 1550 GOSUB 1700:PG=VAL(IN$):IF IN$="" THEN PRINT "[147]":GOTO 170 1560 IF PG<13 OR (PG>15 AND PG<32) OR (PG>63 AND PG<128) OR PG>255 THEN 1540 1570 LI=9:COL=4:LE=3:MSG$="[146]..TO PAGE:[146]":GOSUB 1700:PH=VAL(IN$) 1580 IF PH15 AND PH<32) OR (PH>63 AND PH<128) OR PH>255 THEN 1570 1590 PRINT LEFT$(V$,4)TAB(21)"[164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]":PRINT TAB(21)"** TARGET PAGES **" 1600 LI=7:COL=24:LE=3:MSG$="[146]FROM PAGE:[146]":GOSUB 1700:PD=VAL(IN$) 1610 IF PD<13 OR (PD>15 AND PD<32) OR (PD>63 AND PD<128) OR PD>255 THEN 1600 1620 PE=PD+PH-PG:IF PE>255 THEN PE=255 1630 PRINTLEFT$(V$,9)TAB(23)"..TO PAGE:"PE 1640 IF PD>PG AND PD<=PH THEN 1670 1650 FOR I=PD TO PE:PRINT LEFT$(V$,12)TAB(12)"COPYING PAGE"I 1660 FOR J=0 TO 63:POKE I*64+J,PEEK((PG+I-PD)*64+J):NEXT:NEXT:PRINT "[147]":GOTO 170 1670 FOR I=PE TO PD STEP -1:PRINT LEFT$(V$,12)TAB(12)"COPYING PAGE"I 1680 FOR J=0 TO 63:POKE I*64+J,PEEK((PG+I-PD)*64+J):NEXT:NEXT:PRINT "[147]":GOTO 170 1690 END 1695 REM **************************** 1696 REM * * 1697 REM * INPUT ROUTINE * 1698 REM * * 1699 REM **************************** 1700 Y9=2:IN$="":UC=0:UB$=LEFT$(BL$,LE):GOSUB 1800:UB$=" ":UC=3 1710 UT=TI 1720 GET Z9$:IF Z9$="" THEN 1780 1730 IF Z9$=CR$ THEN Y9=2:GOSUB 1800:PRINT "[157][157] ":RETURN 1740 IF Z9$=DE$ THEN ON -(LEN(IN$)=0) GOTO 1780:IN$=LEFT$(IN$,LEN(IN$)-1):GOTO1780 1750 IF (ASC(Z9$)AND127)<32 OR Z9$=CHR$(34) THEN 1780 1760 IF LE=LEN(IN$) THEN 1780 1770 IN$=IN$ + Z9$ 1780 GOSUB 1800:IF TI-UT<10 THEN 1720 1790 Y9=3-Y9:GOTO 1710 1800 PRINT LEFT$(V$,LI)TAB(COL-1)MID$(MSG$,Y9)UB$IN$MID$(" [146]",Y9,UC)" ";:RETURN 1805 REM **************************** 1806 REM * * 1807 REM * CHECK FOR DISK ERRORS * 1808 REM * * 1809 REM **************************** 1810 INPUT#1,A$,B$,C$,D$ 1820 IF VAL(A$)=0 THEN RETURN 1830 PRINT"[147]DISK ERROR:[146] "B$ 1840 CLOSE2 1850 END 1855 REM **************************** 1856 REM * * 1857 REM * VIEW SPRITE IN MOTION * 1858 REM * * 1859 REM **************************** 1860 POKE G+21,0:PRINT "[147]":POKE G+16,0 1870 X=INT(RND(1)*100)+155:Y=INT(RND(1)*100)+75:DX=4:DY=2:X2=0:Y2=0 1880 POKE G,X:POKE G+1,Y:POKE G+21,1 1890 B$=" ":X=X+DX:Y=Y+DY:GET A$:IF A$<>"" THEN 1950 1900 IF X>255 THEN X=255:DX=-DX 1910 IF Y>200 THEN Y=200:DY=-DY 1920 IF X<65 THEN X=65:DX=-DX 1930 IF Y<75 THEN Y=75:DY=-DY 1940 GOTO 1880 1950 IF A$="+" THEN DX=DX+SGN(DX):DY=DY+SGN(DY):DX=DX-(DX=0):DY=DY-(DY=0) 1960 IF A$="-" THEN DX=DX-SGN(DX):DY=DY-SGN(DY):DX=DX+(DX=0):DY=DY+(DY=0) 1970 IF A$="+" OR A$="-" THEN 1890 1980 IF A$="" THEN B=(B+1)AND15:POKE 53281,B 1990 IF A$="" THEN E=(E+1)AND15:POKE 53280,E 2000 IF A$=">" THEN C=(C+1)AND15:POKE G+39,C 2010 IF A$="" THEN X2=1-X2:POKE G+29,X2 2020 IF A$="" THEN Y2=1-Y2:POKE G+23,Y2 2030 IF A$=CR$ THEN POKE G+21,0:RETURN 2040 IF A$<>B$ THEN 1890 2050 GET B$:A$=B$:IF B$<>" " THEN 1980 2060 GOTO 1890